﻿<%@ Page Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true" CodeBehind="NewsHouses.aspx.cs" Inherits="NEWS.Admin.NewsHouses" %>

<asp:Content ID="content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<script type="text/javascript">
        function confirmAction()
         {
            if(confirm('Xoá tin này đồng thời kết thúc việc đăng và quảng cáo\n hiện tại của tin. Bạn chắn chắn muốn xoá ?'))
            {
                // you clicked the OK button.
                // you can allow the form to post the data.
                return true;
            }
            else 
                // you clicked the Cancel button.
                // you can disallow the form submission.
                return false;
         }
         
         function confirmApprove()
         {
            if(confirm('Bạn có chắc chắn muốn duyệt tin ?'))
            {
                // you clicked the OK button.
                // you can allow the form to post the data.
                return true;
            }
            else 
                // you clicked the Cancel button.
                // you can disallow the form submission.
                return false;
         }
</script>
<script type="text/javascript">
    function SelectAll(CheckBox)
    {
        TotalChkBx = parseInt('<%= this.GridView1.Rows.Count %>');    
        var TargetBaseControl = document.getElementById('<%= this.GridView1.ClientID %>');
        var TargetChildControl = "chkSelect";   
        var Inputs = TargetBaseControl.getElementsByTagName("input");
        for(var iCount = 0; iCount < Inputs.length; ++iCount)
        {                
            if(Inputs[iCount].type == 'checkbox' && Inputs[iCount].id.indexOf(TargetChildControl,0) >= 0)
                Inputs[iCount].checked = CheckBox.checked;   
        }
    }
    function SelectDeSelectHeader(CheckBox)
    {        
        TotalChkBx = parseInt('<%= this.GridView1.Rows.Count %>');    
        var TargetBaseControl = document.getElementById('<%= this.GridView1.ClientID %>');
        var TargetChildControl = "chkSelect";   
        var TargetHeaderControl = "chkSelectAll";   
        var Inputs = TargetBaseControl.getElementsByTagName("input");
        var flag = false;
        var HeaderCheckBox;
        for(var iCount = 0; iCount < Inputs.length ; ++iCount)
        {    
            if(Inputs[iCount].type == 'checkbox' && Inputs[iCount].id.indexOf(TargetHeaderControl,0) >= 0)            
                HeaderCheckBox = Inputs[iCount];            
            if(Inputs[iCount] != CheckBox && Inputs[iCount].type == 'checkbox' && Inputs[iCount].id.indexOf(TargetChildControl,0) >= 0 && Inputs[iCount].id.indexOf(TargetHeaderControl,0) == -1)
            {            
                if(CheckBox.checked)
                {                    
                    if(!Inputs[iCount].checked)                    
                    {                    
                        flag = false;
                        HeaderCheckBox.checked = false;                       
                        return;
                    }
                    else
                        flag = true;                    
                }
                else if(!CheckBox.checked)                
                    HeaderCheckBox.checked = false;                                                       
            }            
        }                      
        if(flag)        
            HeaderCheckBox.checked = CheckBox.checked        
    }
</script>
<script type="text/javascript" src="js/javascrips.js"></script>
<style type="text/css">
    #dhtmltooltip
    {
        position: absolute;
        left: -300px;
        width: 150px;
        border: 1px solid green;
        padding: 2px;
        background-color: HighlightText;
        visibility: hidden;
        z-index: 100; /*Remove below line to remove shadow. Below line should always appear last within this CSS*/
    }
    #dhtmlpointer
    {
        position: absolute;
        left: -300px;
        z-index: 101;
        visibility: hidden;
    }
</style>
<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager>
 <asp:UpdatePanel ID="UpdatePanel1" runat="server" >
     <ContentTemplate>
           <asp:Panel ID="PanelDasboard" runat="server"  Visible="true">           
            <div class="dashboard">                
                <asp:Panel ID="pn_result" Visible="false" runat="server">                
                    <div style="border:solid 1px coral; width:100%; text-align:center; height:30px; background:#FFFFCC; margin-bottom:10px;">                    
                        <asp:Label style="line-height:25px;" ID="lblthongbao" runat="server" Text="Thông Báo" ForeColor="Black" 
                            Font-Bold="True"></asp:Label>
                    </div>
                </asp:Panel>    
                <h2 class="ico_mug">
                    <asp:Label ID="lblview_approve" runat="server" Text="Danh sách tin nhà đất"></asp:Label>                
                </h2>
                <asp:Panel ID="pn_view" runat="server">
                    <div style="width:100%; margin-bottom:10px;">
                        <p style="margin-right:10px;float:left;">Xem Theo
                            <asp:DropDownList ID="dlkieuxem" runat="server" AutoPostBack="true" Visible="true" Width="100px" 
                                onselectedindexchanged="dlkieuxem_SelectedIndexChanged">
                                <asp:ListItem Value="tatca">Tất cả</asp:ListItem>
                                <asp:ListItem Value="hethan">Hết hạn</asp:ListItem>
                                <asp:ListItem Value="traphi">Trả phí</asp:ListItem>
                            </asp:DropDownList>
                        </p>
                        <p style="margin-right:10px;float:left;"><asp:LinkButton ID="btndangtin" 
                                runat="server" Font-Bold="True" ForeColor="Blue" Visible="true" 
                                onclick="btndangtin_Click">Đăng tin</asp:LinkButton></p>
                        <p><asp:LinkButton ID="btnxoatin" runat="server" Font-Bold="True" ForeColor="Blue" 
                                Visible="true" OnClientClick="javascript:return confirmAction();" 
                                onclick="btnxoatin_Click">Xóa Tin Được Chọn</asp:LinkButton></p>
                    </div>
                </asp:Panel>
                <asp:Panel ID="pn_approve" Visible="false" runat="server">
                    <div style="width:100%; margin-bottom:10px;">
                        <p style="margin-right:10px;float:left;">Xem Theo
                            <asp:DropDownList ID="dlviewapprove" runat="server" AutoPostBack="true" 
                                Visible="true" Width="200px" 
                                onselectedindexchanged="dlviewapprove_SelectedIndexChanged">
                                <asp:ListItem Value="quangcao">Tin Quảng Cáo</asp:ListItem>
                                <asp:ListItem Value="mienphi">Tin Miễn Phí</asp:ListItem>
                                <asp:ListItem Value="moigiahan">Tin Mới Gia Hạn</asp:ListItem>
                            </asp:DropDownList>
                        </p>
                        <p style="padding:4px;">
                            <asp:Button ID="btnapprove" OnClientClick="javascript:return confirmApprove();" runat="server" Text="Duyệt Tin Được Chọn" 
                                onclick="btnapprove_Click" />
                            <asp:Button ID="btnapproveall" OnClientClick="javascript:return confirmApprove();" runat="server" Text="Duyệt Tất Cả" 
                                onclick="btnapproveall_Click" />
                        </p>
                    </div>
                </asp:Panel>
                    <div>
                        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                            CellPadding="4" DataKeyNames="NewsHouseID" Width="100%" onselectedindexchanged="GridView1_SelectedIndexChanged" AllowPaging="True" 
                            ForeColor="#333333" GridLines="None" 
                            onrowdatabound="GridView1_RowDataBound" 
                            onrowcommand="GridView1_RowCommand">
                            <FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True" />
                            <RowStyle BackColor="#EFF3FB" />
                            <Columns>
                                <asp:CommandField ButtonType="Image" SelectImageUrl="~/Admin/img/edit.png" 
                                    ShowSelectButton="True" >
                                    <HeaderStyle Width="30px" />
                                </asp:CommandField>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:ImageButton ID="IBdelete" runat="server" onclientclick="javascript:return confirmAction();" CommandName="delete" 
                                            ImageUrl="~/Admin/img/cancel.png" />
                                    </ItemTemplate>
                                    <HeaderStyle Width="30px" />
                                </asp:TemplateField>                            
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:CheckBox ID="chkSelect" runat="server" />
                                    </ItemTemplate>
                                    <HeaderTemplate>
                                     <asp:CheckBox ID="chkSelectAll" runat="server" onclick="SelectAll(this);" />                                
                                    </HeaderTemplate>
                                    <HeaderStyle HorizontalAlign="Center" Width="20px" />
                                    <ItemStyle HorizontalAlign="Center" />
                                </asp:TemplateField>
                                <asp:BoundField DataField="NewsHouseID" HeaderText="Mã Tin" 
                                    SortExpression="NewsHouseID" >
                                    <HeaderStyle HorizontalAlign="Center" Width="45px" />
                                    <ItemStyle HorizontalAlign="Center" />
                                </asp:BoundField>
                                <asp:TemplateField HeaderText="Tiêu Đề">
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lbttitle" runat="server" Text='<%# Eval("Title") %>' 
                                            CommandName="Xem2"></asp:LinkButton>
                                    </ItemTemplate>
                                    <HeaderStyle HorizontalAlign="Left" />
                                    <ItemStyle HorizontalAlign="Left" />
                                </asp:TemplateField>
                                <asp:BoundField DataField="CreatedDate" DataFormatString="{0:dd/MM/yyyy}" 
                                    HeaderText="Ngày Đăng" SortExpression="CreatedDate">
                                    <HeaderStyle HorizontalAlign="Left" Width="70px" />
                                    <ItemStyle HorizontalAlign="Left" />
                                </asp:BoundField>
                                <asp:TemplateField HeaderText="Kích hoạt">
                                    <ItemTemplate>
                                        <asp:CheckBox ID="kichhoat" runat="server" Enabled="False" 
                                            Checked='<%# Bind("IsActive") %>' />
                                    </ItemTemplate>
                                    <HeaderStyle HorizontalAlign="Center" Width="70px" />
                                    <ItemStyle HorizontalAlign="Center" />
                                </asp:TemplateField>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:Label ID="lblimage" runat="server" Text='<%# Eval("UrlImage") %>' 
                                            Visible="False"></asp:Label>
                                        <asp:Label ID="lbldientich" runat="server" Text='<%# Eval("SurfaceAreaWidth") %>' 
                                            Visible="False"></asp:Label>
                                        <asp:Label ID="lblvitri" runat="server" Visible="False" 
                                            Text='<%# Eval("AreaDetailName") %>'></asp:Label>
                                        <asp:Label ID="lblgia" runat="server" Text='<%# Eval("Price") %>' 
                                            Visible="False"></asp:Label>
                                        <asp:Label ID="lblmota" runat="server" Text='<%# Eval("Direction") %>' 
                                            Visible="False"></asp:Label>
                                        <asp:Label ID="lbldientichdai" runat="server" 
                                            Text='<%# Eval("SurfaceAreaHeight") %>' Visible="False"></asp:Label>
                                        <asp:Label ID="lblloaitien" runat="server" Text='<%# Eval("CurrencyName") %>' 
                                            Visible="False"></asp:Label>
                                        <asp:CheckBox ID="cbSup" runat="server" Checked='<%# Bind("SupM") %>' 
                                            Visible="False" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Chọn Tin">                                    
                                    <ItemTemplate>
                                        <asp:CheckBox ID="cbapprove" runat="server" />
                                    </ItemTemplate>                                    
                                    <HeaderStyle Width="50px" HorizontalAlign="Center" />
                                    <ItemStyle HorizontalAlign="Center" />
                                </asp:TemplateField>
                            </Columns>
                            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                            <EditRowStyle BackColor="#2461BF" />
                            <AlternatingRowStyle BackColor="White" />
                        </asp:GridView>
                        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
                            SelectMethod="GetAllNewsHousesBOList" 
                            TypeName="HousingInfo.Library.NewsHouseBOList">
                        </asp:ObjectDataSource>
                        <asp:Label ID="messagedelete" runat="server" Font-Bold="True" Font-Size="Small" 
                            ForeColor="Red"></asp:Label>
                        <br />
                    </div>               
            </div>
       </asp:Panel>
  </ContentTemplate>
 </asp:UpdatePanel>
</asp:Content>
